<?php $post = $this->getPost();?>
<div id="messages_product_view"><?php echo $this->getMessagesBlock()->getGroupedHtml() ?></div>
<div class="case_tudy02 page">
<?php if($post->getNfile()){?>
<div class="news_img02">
<img src="<?php echo Mage::getModel('imageresize/imagemodel')->init(Mage::getBaseUrl('media').$post->getNfile())->resize(223)?>" alt="<?php echo $post->getNfileAlt()?>" />
</div>
<?php }?>
<h2 class="title01"><span><img src="<?php echo $this->getSkinUrl()?>images/image_01.gif" alt="" width="19" height="19" /></span>Products: <?php echo $post->getTitle()?></h2>
<?php echo $post->getPostContent(); ?>

<div class="turnkey_images">
<h2 class="title01"><span><img src="<?php echo $this->getSkinUrl()?>images/image_01.gif" alt="" width="19" height="19" /></span>Project Images</h2>
<ul>
<?php 
$tImage=$post->getImagegallery();
$imageCount=0;

if($tImage && is_array(json_decode($tImage,true))){
	$tImage=json_decode($tImage,true);
	$outputstring=array();
	
	foreach ($tImage as $image){
		$imageCount++;
		if($imageCount>4){
			break;
		}
		$url = @$image['filepath'];
		$desc = @$image['filename'];
		$pos = @$image['filepos'];
		//$linkurl = @$image['linkurl'];
		
		$imagestring='<li><a href="'.Mage::getModel('imageresize/imagemodel')->init(Mage::getBaseUrl('media').$url)->resize().'" rel="shadowbox" title="'.$desc.'"><img src="'.Mage::getModel('imageresize/imagemodel')->init(Mage::getBaseUrl('media').$url)->resize(145,114).'" alt="'.$desc.'" /></a></li>';
		if($pos!=""){
			if(!isset($outputstring[$pos])){
				$outputstring[$pos]=$imagestring;
			}else{
				$outputstring[$pos].=$imagestring;
			}
		}else{
			$outputstring[]=$imagestring;
		}
		
	}
	echo implode("\n",$outputstring);
}

for ($i=4-$imageCount;$i>0;$i--){
	echo '<li></li>';
}

?>
</ul>
<div class="hack"></div>
</div>

<?php 
$tFile=$post->getFilegallery();
$fileCount=0;
unset($outputstring);

if($tFile && is_array(json_decode($tFile,true))){
	?>
	<h2 class="title01"><span><img src="<?php echo $this->getSkinUrl()?>images/image_01.gif" alt="" width="19" height="19" /></span>Project Downloads</h2>
	<div>
	<?php 
	$tFile=json_decode($tFile,true);
	$outputstring=array();
	
	foreach ($tFile as $file){
		$fileCount++;

		$url = @$file['filepath'];
		$desc = @$file['filename'];
		$pos = @$file['filepos'];
		//$linkurl = @$image['linkurl'];
		if(!$desc){
			$desc=basename($url);
		}
		
		$filestring='<p>'.$desc.' <a href="'.Mage::getBaseUrl('media').$url.'" target="_blank"><strong class="tt">Click Here</strong></a></p>';
		if($pos!=""){
			if(!isset($outputstring[$pos])){
				$outputstring[$pos]=$filestring;
			}else{
				$outputstring[$pos].=$filestring;
			}
		}else{
			$outputstring[]=$filestring;
		}
	}
	echo implode("\n",$outputstring);
	?>
	</div>
	<?php 
}

?>

</div>